<?php

namespace app\api\controller\v1\activity;

use app\Request;
use app\services\activity\free\StoreFreeServices;

/**
 * 满赠商品
 * Class StoreSeckillController
 * @package app\api\controller\activity
 */
class StoreFreeController
{

    protected $services;

    public function __construct(StoreFreeServices $services)
    {
        $this->services = $services;
    }

    /**
     * 秒杀商品列表
     * @param $time
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function lst($time)
    {
        if (!$time) return app('json')->fail(100100);
        $seckillInfo = $this->services->getListByTime($time);
        return app('json')->success(get_thumb_water($seckillInfo));
    }

    /**
     * 秒杀商品详情
     * @param Request $request
     * @param $id
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function detail(Request $request, $id)
    {
        $data = $this->services->freeDetail($request, $id);
        return app('json')->success($data);
    }
}
